package com.deer.wms.ureport.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.deer.wms.ureport.dao.Test2Mapper;
import com.deer.wms.ureport.model.Test2;
import com.deer.wms.ureport.service.Test2Service;
import org.apache.ibatis.exceptions.TooManyResultsException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by  on 2021/02/04.
 */
@Service
@Transactional
public class Test2ServiceImpl extends ServiceImpl<Test2Mapper, Test2> implements Test2Service {

    @Autowired
    private Test2Mapper test2Mapper;

    @Override
    public void save(List<Test2> models) {
        super.saveBatch(models);
    }

    @Override
    public void deleteById(Integer id) {
        super.removeById(id);
    }

    @Override
    public void update(Test2 model) {
        super.updateById(model);
    }

    @Override
    public Test2 findById(Integer id) {
        return super.getById(id);
    }

    @Override
    public Test2 findBy(String fieldName, Object value) throws TooManyResultsException {
        QueryWrapper<Test2> qw = new QueryWrapper<>();
        return super.getOne(qw.eq(fieldName, value));
    }

    @Override
    public List<Test2> findAll() {
        return super.list();
    }
}
